import store from 'store'
export const userKey = 'user-info'
export const TokenKey = 'authorized-token'

/** 获取`token` */
export function getToken() {
  return store.get(TokenKey)
}

export function setUser(data: string) {
  store.set(userKey, data)
  setToken(data)
}
export function getUserInfo() {
  return store.get(userKey)
}
export function removeToken() {
  store.remove(TokenKey)
}
export function setToken(token: string) {
  store.set(TokenKey, token)
}

/** 格式化token（jwt格式） */
export const formatToken = (token: string): string => {
  return 'Bearer ' + token
}
